﻿#include "MainWorld.h"
#include "opengl/ssOpenGLSupport.h"


CMainWorld::CMainWorld(void)
{
	m_gameWorld.Init();
}

CMainWorld::~CMainWorld(void)
{
}

void CMainWorld::Render()
{
	SS_OPENGL->BeginRender();

	m_gameWorld.Render();

	SS_OPENGL->EndRender();
	SS_OPENGL->SwapBuffers();
}

void CMainWorld::OnClose()
{
}

void CMainWorld::OnMouseMove(int x, int y, unsigned int state)
{
	if (state&MK_RBUTTON)//按键按下
	{
		POINT ChangedPoint = {x-m_RLastPoint.x, y-m_RLastPoint.y};
		m_RLastPoint.x = x;
		m_RLastPoint.y = y;
		m_gameWorld.OnMouseMove(ChangedPoint.x, ChangedPoint.y);
	}
}
void CMainWorld::OnRButtonDown( int x, int y, unsigned int state )
{
	m_RLastPoint.x = x;
	m_RLastPoint.y = y;
	//SetFocus();
}
void CMainWorld::OnLButtonDown(int x, int y, unsigned int state)
{
	m_LLastPoint.x = x;
	m_LLastPoint.y = y;
}
void CMainWorld::OnMouseWheel(short wheel, unsigned int state)
{
	m_gameWorld.OnMouseWheel(wheel);
}
void CMainWorld::OnKeyDown(unsigned int key)
{
	m_gameWorld.OnKeyDown(key);
}
void CMainWorld::OnKeyUp(unsigned int key)
{
	m_gameWorld.OnKeyUp(key);
}
